package tree;

import iterator.Iterator;
import wrapper.Comparable;
import main.LinkedList;

public class GeneralTree extends AbstractTree {
	protected Object key;
	protected int degree;
	protected LinkedList list;

	public Object getKey() {
		return key;
	}

	public Tree getSubtree(int i) {
		if (i < 0 || i >= degree)
			throw new IndexOutOfBoundsException();
		LinkedList.Element ptr = list.getHead();
		for (int j = 0; j < i; ++j)
			ptr = ptr.getNext();
		return (GeneralTree) ptr.getDatum();
	}

	public void attachSubtree(GeneralTree t) {
		list.append(t);
		++degree;
	}

	public GeneralTree detachSubtree(GeneralTree t) {
		list.extract(t);
		--degree;
		return t;
	}

	@Override
	protected int compareTo(Comparable arg) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public Iterator getIterator() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void purge() {
		// TODO Auto-generated method stub

	}

	@Override
	public int getDegree() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int getHeight() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public boolean isLeaf() {
		// TODO Auto-generated method stub
		return false;
	}
}
